<?php

namespace app\common\service;

use app\core\base\AdminOpLogModel;
use app\common\InstanceTrait;

class AdminOpLogService
{
    use InstanceTrait;

    const ADMIN_OP_TYPE_CREATE = 1;
    const ADMIN_OP_TYPE_UPDATE = 2;
    const ADMIN_OP_TYPE_DELETE = 3;
    const ADMIN_OP_TYPE_CHANGE_PASS = 4;
    const ADMIN_OP_TYPE_LOGIN = 5;
    const ADMIN_OP_TYPE_LOGIN_FORCE = 6;
    const ADMIN_OP_TYPE_LOGOUT = 7;
    /********************
* 343系统
*********************/
    const ADMIN_OP_OBJ_ADMIN_USER = "admin_user";//管理员
    const ADMIN_OP_OBJ_PRICE_ADMIN = "price_admin";//文章价格
    const ADMIN_OP_OBJ_LOTTERY = "lottery";//开奖
    //公告
    const ADMIN_OP_OBJ_ABS_PUBLISHER = "ads_publisher";
    const ADMIN_OP_OBJ_ABS_BANNER = "ads_banner";
    const ADMIN_OP_OBJ_ABS_INSTANCE = "ads_instance";
    const ADMIN_OP_OBJ_ABS_TYPE = "ads_type";
    //文章
    const ADMIN_OP_OBJ_BLOGO_TYPE = "blog_type";
    const ADMIN_OP_OBJ_BLOGO_INSTANCE = "blog_instance";
    const ADMIN_OP_OBJ_BLOGO_COMMENT = "blog_comment";
    const ADMIN_OP_OBJ_BLOGO_REPLY = "blog_reply";
    const ADMIN_OP_OBJ_CAROUSEL_BANNER_INSTANCE_RELATE = "carousel_banner_instance_relate";
    const ADMIN_OP_OBJ_CAROUSEL_INSTANCE = "carousel_instance";
    //专家
    const ADMIN_OP_OBJ_EXPERT_FORECAST = "expert_forecast";
    const ADMIN_OP_OBJ_EXPERT_USER = "expert_user";
    //虚拟用户
    const ADMIN_OP_OBJ_USER_000 = "user_000";
    //友链
    const ADMIN_OP_OBJ_FRIENDLY_LINK = "friendly_link";
    //会员
    const ADMIN_OP_OBJ_MEMBER_CONFIG = "member_config";
    //公告
    const ADMIN_OP_OBJ_NOTICE = "notice";
    //岗位
    const ADMIN_OP_OBJ_ROLE = "role";
    const ADMIN_OP_OBJ_ROLE_ROUTE = "role_route";
    //标签
    const ADMIN_OP_OBJ_TAG = "tag";
    //创建用户
    const ADMIN_OP_OBJ_USER = "user";
    const ADMIN_OP_STATUS_SUCCESS = 0;
    const ADMIN_OP_STATUS_FAIL = 1;
    /********************
* 体育系统（列：ADMIN_OP_STATUS_FAIL_SPORTS）加体育单词方便区分
*********************/
    const ADMIN_OP_OBJ_USER_FEEDBACK = "user_feedback";//用户反馈

    public function addLog($type, $object, $status, $ip, $dataOld, $dataNew, $adminId, $employeeNo, $sys = 343)
    {
        $data = [
            "data" => $dataNew,
            "data_old" => $dataOld,
        ];
        $data = json_encode($data);
        AdminOpLogModel::getInstance()->insertAdminOpLog(
            [
            "admin_id" => $adminId,
            "employee_no"=> $employeeNo,
            "op_type"=> $type,
            "op_object"=> $object,
            "op_info"=> $data,
            "op_status"=> $status,
            "op_ip" => $ip,
            "sys" => $sys
            ]
        );
    }
}
